﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;

namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类LitigationSub 的摘要说明。
    /// </summary>
    public class LitigationSub
    {
        public LitigationSub()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo GetModel(Guid MainId)
        {
            return Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.GetModel(MainId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.GetList(strWhere);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.t_Business_LitigationSubInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo> modelList = new List<Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.t_Business_LitigationSubInfo();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["MainId"].ToString() != "")
                    {
                        model.MainId = new Guid(dt.Rows[n]["MainId"].ToString());
                    }
                    if (dt.Rows[n]["FirstTrialDate"].ToString() != "")
                    {
                        model.FirstTrialDate = DateTime.Parse(dt.Rows[n]["FirstTrialDate"].ToString());
                    }
                    model.FirstTrialCourt = dt.Rows[n]["FirstTrialCourt"].ToString();
                    model.FirstTrialJudge = dt.Rows[n]["FirstTrialJudge"].ToString();
                    model.FirstTrialMemo = dt.Rows[n]["FirstTrialMemo"].ToString();
                    if (dt.Rows[n]["SecTrialDate"].ToString() != "")
                    {
                        model.SecTrialDate = DateTime.Parse(dt.Rows[n]["SecTrialDate"].ToString());
                    }
                    model.SecTrialCourt = dt.Rows[n]["SecTrialCourt"].ToString();
                    model.SecTrialJudge = dt.Rows[n]["SecTrialJudge"].ToString();
                    model.SecTrialMemo = dt.Rows[n]["SecTrialMemo"].ToString();
                    if (dt.Rows[n]["LastTrialDate"].ToString() != "")
                    {
                        model.LastTrialDate = DateTime.Parse(dt.Rows[n]["LastTrialDate"].ToString());
                    }
                    model.LastTrialCourt = dt.Rows[n]["LastTrialCourt"].ToString();
                    model.LastTrialJudge = dt.Rows[n]["LastTrialJudge"].ToString();
                    model.LastTrialMemo = dt.Rows[n]["LastTrialMemo"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion  成员方法
    }
}
